/*
 * Background Flickr: Copyright (C) 2009  Craig McNicholas
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.ddw.app.bflickr.flickr.api.response;

import java.util.Vector;

import com.ddw.app.bflickr.flickr.api.FlickrPhoto;
import com.ddw.app.bflickr.logging.Log;
import com.ddw.app.bflickr.logging.LogFactory;

/**
 * Class to hold a flickr photos responses data including the photos 
 * that have been found if any. Other information includes the number 
 * of pages and photos found and what page the request returned.
 * @author craig
 *
 */
public class FlickrPhotosResponse extends FlickrApiResponse {

	private Log log = LogFactory.createInstance(this.getClass());
	private Vector<FlickrPhoto> photos = null;
	private int page = 1;
	private int pages = 0;
	private int totalPictures = 0;
	
	/**
	 * Getter of the found photos. <b>This object is <u>null</u> by default</b>
	 * @return the flickr photos that were found by a get photos request
	 */
	public Vector<FlickrPhoto> getPhotos() {
		return this.photos;
	}
	
	/**
	 * Getter for the page number that was returned as part of the response. This may
	 * differ from the page number set in the url if the page requested was out of 
	 * bounds.
	 * @return the current page number of photos returned in the request
	 */
	public int getPage() {
		return this.page;
	}
	
	/**
	 * Getter for the total number of pages found in the request.
	 * @return the total number of pages found, <b>by default this is <i>zero</i></b>
	 */
	public int getTotalPages() {
		return this.pages;
	}
	
	/**
	 * Getter for the total number of photos <u>returned across all pages</u> and not 
	 * just this single request.
	 * @return the total number of photos <b>found across all pages</b> in the request
	 */
	public int getTotalPhotos() {
		return this.totalPictures;
	}
	
	/**
	 * Setter for the flickr photos found from this request. 
	 * @param photos the flickr photos to set
	 */
	public void setPhotos(Vector<FlickrPhoto> photos) {
		if(photos == null) {
			log.error("The photos vector cannot be null");
			throw new IllegalArgumentException("The photos vector cannot be null");
		}
		this.photos = photos;
	}
	
	/**
	 * Setter for the the page number that was returned in the request.
	 * @param page the page number
	 */
	public void setPage(int page) {
		if(page < 1) {
			log.error("The page cannot be less than one");
			throw new IllegalArgumentException("The page cannot be less than one");
		}
		this.page = page;
	}
	
	/**
	 * Setter for the total number of pages found in this request.
	 * @param total the total number of pages found
	 */
	public void setTotalPages(int total) {
		if(total < 0) {
			log.error("The total number of pages cannot be less than 0");
			throw new IllegalArgumentException("The total number of pages cannot be less than 0");
		}
		this.pages = total;
	}
	
	/**
	 * Setter for the total number of photos found <u>across all pages</u> in this request.
	 * @param total the total number of photos found <b>across all pages</b>
	 */
	public void setTotalPhotos(int total) {
		if(total < 0) {
			log.error("The total number of photos cannot be less than 0");
			throw new IllegalArgumentException("The total number of photos cannot be less than 0");
		}
		this.totalPictures = total;
	}
	
}
